import subprocess
def ping(host_ip):
    r=subprocess.run('ping -c2 -i0.2 -w1 %s &> /dev/null' %host_ip,shell=True)
    if r.returncode==0:
        print(host_ip,':up')

    else:
        print(host_ip,':down')
if __name__ == '__main__':   #只有在自己调用自己的时候才执行
    for i in range(1,250):
        host_ip="176.121.213.%d" %i
        ping(host_ip)
# 导入 paramiko 模块
#import paramiko

#ssh_clint=paramiko.SSHClient()
